<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>LRY-小说规则列表</title>
<link rel="icon" href="../static/favicon.ico" type="image/ico">
<meta name="keywords" content="LRY 聚合系统">
<meta name="description" content="LRY 聚合系统">
<meta name="author" content="pingc">
<link th:href="@{/static/css/bootstrap.min.css}" rel="stylesheet">
<link th:href="@{/static/css/materialdesignicons.min.css}" rel="stylesheet">
<link th:href="@{/static/css/animate.css}" rel="stylesheet">
<link th:href="@{/static/css/style.min.css}" rel="stylesheet">
</head>
<style type="text/css">
  table {
  table-layout: fixed;
  word-break: break-all;
  }
  td {white-space:nowrap;overflow:hidden;word-break:keep-all;text-overflow:ellipsis}
</style>
<body>
<div class="container-fluid p-t-15">
  
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-toolbar clearfix">
          <div class="toolbar-btn-action">
            <a class="btn btn-primary m-r-5" th:href="@{/admin/fiction_variable_add}"><i class="mdi mdi-plus"></i> 新增</a>
            <a class="btn btn-danger pst" href="javascript:void(0)" ><i class="mdi mdi-delete"></i> 删除</a>
          </div>
        </div>
        <div class="card-body">
          
          <div class="table-responsive">
            <table class="tree-table table table-bordered table-hover" >
              <thead>
                <tr>
                  <th width="3%">
                    <label class="lyear-checkbox checkbox-primary">
                      <input type="checkbox" id="check-all"><span></span>
                    </label>
                  </th>
                  <th>规则名称</th>
                  <th>源站网址</th>
                  <th>源站协议</th>
                  <th>搜索链接</th>
                  <th>搜索下页</th>
                  <th>搜索标题</th>
                  <th>搜索链接</th>
                  <th>小说标题</th>
                  <th>小说作者</th>
                  <th>小说分类</th>
                  <th>小说简介</th>
                  <th>小说封面</th>
                  <th>更新时间</th>
                  <th>章节标题</th>
                  <th>章节链接</th>
                  <th>章节内容</th>
                  <th>创建时间</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody th:each="f : ${fictionVariables}">
                <tr>
                  <td width="50px" class="bs-checkbox " data-field="check">
                    <label class="lyear-checkbox checkbox-primary ">
                      <input type="checkbox" name="fictionV" th:value="${f.id}"><span></span>
                    </label>
                  </td>
                  <td th:text="${f.name}" ></td>
                  <td th:text="${f.url}"></td>
                  <td th:text="${f.protocol}"></td>
                  <td th:text="${f.searchUrl}"></td>
                  <td th:text="${f.page}"></td>
                  <td th:text="${f.fictionTitle}"></td>
                  <td th:text="${f.fictionUrl}"></td>
                  <td th:text="${f.title}"></td>
                  <td th:text="${f.author}"></td>
                  <td th:text="${f.fictionType}"></td>
                  <td th:text="${f.descs}"></td>
                  <td th:text="${f.cover}"></td>
                  <td th:text="${f.updateTime}"></td>
                  <td th:text="${f.chapterTitle}"></td>
                  <td th:text="${f.chapterUrl}"></td>
                  <td th:text="${f.content}"></td>
                  <td th:text="${#dates.format(f.creationTime,  'yyyy-MM-dd HH:mm:ss')}"></td>

                  <td>
                    <div class="btn-group">
                      <a class="btn btn-xs btn-default" th:href="@{/admin/fiction_variable_add/{id} (id=${f.id})}" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                      <a class="btn btn-xs btn-default "  title="删除" data-toggle="tooltip"  href="javascript:void(0)"  th:onclick="showDeleteModal([[${f.Id}]]);" ><i class="mdi mdi-delete"></i></a>
                    </div>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <ul class="pagination">
            <li><a href="#" th:if="${from} le 1">«</a></li>
            <li><a th:href="@{/admin/fiction_variable_list/{from}/{size} (from=${from} - 1,size=10)}" th:if="${from} gt 1">«</a></li>
            <li><a th:href="@{/admin/fiction_variable_list/{from}/{size} (from=${from} - 2,size=10)}" th:if="${from}-2 gt 0" th:text="${from} -2"></a></li>
            <li><a th:href="@{/admin/fiction_variable_list/{from}/{size} (from=${from} - 1,size=10)}" th:if="${from}-1 gt 0" th:text="${from} -1"></a></li>
            <li class="active"><span th:text="${from}"></span></li>
            <li><a th:href="@{/admin/fiction_variable_list/{from}/{size}(from=${from} + 1,size=10)}" th:if="${from}+1 le ${pages}" th:text="${from} + 1"></a></li>
            <li><a th:href="@{/admin/fiction_variable_list/{from}/{size} (from=${from} + 2,size=10)}" th:if="${from}+2 le ${pages}" th:text="${from} + 2" ></a></li>
            <li><a th:href="@{/admin/fiction_variable_list/{from}/{size} (from=${from} + 1,size=10)}" th:if="${from} lt ${pages}">»</a></li>
            <li><a href="#" th:if="${from} ge ${pages}">»</a></li>
          </ul>
 
        </div>
      </div>
    </div>
  </div>
</div>

<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" id="delcfmOverhaul">
  <div class="modal-dialog modal-sm" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="myLargeModalLabel">提示</h4>
      </div>
      <div class="modal-body">
        <input type="hidden" id="deleteHaulId" />
        <p>你确定要删除数据吗？</p>
      </div>
      <div class="modal-footer">
        <button type="button" id="gb" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id="deleteHaulBtn">确定</button>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript" th:src="@{/static/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/static/js/bootstrap.min.js}"></script>
<!--消息提示-->
<script th:src="@{/static/js/bootstrap-notify.min.js}"></script>
<script type="text/javascript" th:src="@{/static/js/lightyear.js}"></script>
<script type="text/javascript" th:src="@{/static/js/main.min.js}"></script>
<script type="text/javascript">
  function showDeleteModal(fiction_id) {
    $("#deleteHaulId").val(fiction_id);// 将模态框中需要删除的大修的ID设为需要删除的ID
    $("#delcfmOverhaul").modal({
      backdrop : "static",
    keyboard : false
  });
  }
  function deleteHaulinfo() {
    lightyear.loading('show');
    $('#gb').click();
    //删除操作
    $.ajax({
      type:"get",    //请求类型，POST\GET，不写默认GET
      url:"/fictionVariable/deleteById/"+$("#deleteHaulId").val(),    //请求地址
      dataType:"json",    //ajax接收响应的数据是什么格式。选填，不填时，根据服务端响应的类型 自动判断
      success:function(data){//请求成功回调函数，在服务端成功响应数据之后，调用这个函数，有一个参数，接收返回的数据
        lightyear.loading('hide');
        if(data.code==0){
          lightyear.notify('删除成功，页面即将刷新~', 'success', 3000);
          setTimeout(function () { window.location.reload();}, 2000)
        }else {
          lightyear.notify('服务器错误，请稍后再试~', 'danger', 100);
        }
      },
      error:function(jqXHR,textStatus,errorThrown){    //请求失败调用的函数，共有三个参数。选填，可不填
        lightyear.loading('hide');
        lightyear.notify('服务器错误，请稍后再试~', 'danger', 100);
      }
    })
  }
  $(function() {
// 删除的确定按钮的点击事件
    $("#deleteHaulBtn").click(function() {
// ajax异步删除
      deleteHaulinfo();

    });

  });

  //使用下面的示例之前，应当先加载jquery.js插件
  $('.pst').on("click", function () {
    var str = "";
    $("input[name='fictionV']:checked").each(function (index, item) {
      if ($("input[name='fictionV']:checked").length - 1 == index) {
        str += $(this).val();
      } else {
        str += $(this).val() + ",";
      }
    });
    if(str.length==0){
      alert("请至少选择一条数据");
    }else{
      showDeleteModal(str)
    }

  });

  function ec(i,z) {
    $("#search-btn").html(i+" <span class='caret'></span>");
    $("#optionz").attr("value",z);
  };


</script>
</body>
</html>